//
//  LLMainTabBar.swift
//  WeiBoShiBing
//
//  Created by Bingo on 15/10/27.
//  Copyright © 2015年 Bingo. All rights reserved.
//

import UIKit

class LLMainTabBar: UITabBar {
    
    private let count:CGFloat = 5
    //添加发表说说按钮到tabBar上
    override func layoutSubviews() {
        super.layoutSubviews()
        let width = bounds.width / count
        let frame = CGRect(x: 0, y: 0, width: width, height: bounds.height)
        var index = 0
        for view in subviews{
            //遍历tabBar子控件，如果子控件是继承自uicontrol且不是UIButton控件就设置其frame
            if view is UIControl && !(view is UIButton){
                view.frame = CGRectOffset(frame, width * CGFloat(index), 0)
                //留出第二个位置给发表说说按钮
                index += index == 1 ? 2 :1
            }
        }
    }
    
}
